<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>3D旋转魔方特效</title>
    <style>
      * {
        margin: 0;
        padding: 0;
        list-style: none;
      }
      body {
        background: #333;
        /* 视距 */
        perspective: 800px;
      }
      .box {
        width: 200px;
        height: 200px;
        margin: 300px auto;
        transform-style: preserve-3d;
        -webkit-transform-style: preserve-3d;
        animation: rotate 15s infinite linear;
      }
      .minbox {
        position: absolute;
        width: 100px;
        height: 100px;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        margin: auto;
        box-sizing: border-box;
        transform-style: preserve-3d;
        transform: rotateY(45deg);
      }
      .minbox li {
        width: 100px;
        height: 100px;
        position: absolute;
        top: 0;
        left: 0;
      }
      /* 前 */
      .minbox li:nth-child(1) {
        background: #000 url("https://qiniu.zhangkai2019.cn/image/01.png");
        transform: translateZ(50px);
      }
      /* 后 */
      .minbox li:nth-child(2) {
        background: #000 url("https://qiniu.zhangkai2019.cn/image/02.png");
        transform: rotateX(180deg) translateZ(50px);
      }
      /* 上 */
      .minbox li:nth-child(3) {
        background: #000 url("https://qiniu.zhangkai2019.cn/image/03.png");
        transform: rotateX(90deg) translateZ(50px);
      }
      /* 下 */
      .minbox li:nth-child(4) {
        background: #000 url("https://qiniu.zhangkai2019.cn/image/04.png");
        transform: rotateX(-90deg) translateZ(50px);
      }
      /* 左 */
      .minbox li:nth-child(5) {
        background: #000 url("https://qiniu.zhangkai2019.cn/image/05.png");
        transform: rotateY(-90deg) translateZ(50px);
      }
      /* 右 */
      .minbox li:nth-child(6) {
        background: #000 url("https://qiniu.zhangkai2019.cn/image/06.png");
        transform: rotateY(90deg) translateZ(50px);
      }
      .maxbox li {
        width: 200px;
        height: 200px;
        position: absolute;
        top: 0;
        left: 0;
        opacity: 0.2;
        background: #fff;
        border: 1px solid #ccc;
        transition: transform 0.5s ease;
      }
      /* 前 */
      .maxbox li:nth-child(1) {
        transform: translateZ(100px);
      }
      /* 后 */
      .maxbox li:nth-child(2) {
        transform: rotateX(180deg) translateZ(100px);
      }
      /* 上 */
      .maxbox li:nth-child(3) {
        transform: rotateX(90deg) translateZ(100px);
      }
      /* 下 */
      .maxbox li:nth-child(4) {
        transform: rotateX(-90deg) translateZ(100px);
      }
      /* 左 */
      .maxbox li:nth-child(5) {
        transform: rotateY(-90deg) translateZ(100px);
      }
      /* 右 */
      .maxbox li:nth-child(6) {
        transform: rotateY(90deg) translateZ(100px);
      }
      .box:hover .maxbox li:nth-child(1) {
        transform: translateZ(120px);
      }
      .box:hover .maxbox li:nth-child(2) {
        transform: rotateX(180deg) translateZ(150px);
      }
      .box:hover .maxbox li:nth-child(3) {
        transform: rotateX(90deg) translateZ(150px);
      }
      .box:hover .maxbox li:nth-child(4) {
        transform: rotateX(-90deg) translateZ(150px);
      }
      .box:hover .maxbox li:nth-child(5) {
        transform: rotateY(-90deg) translateZ(150px);
      }
      .box:hover .maxbox li:nth-child(6) {
        transform: rotateY(90deg) translateZ(150px);
      }
      @keyframes rotate {
        form {
          transform: rotateX(0) rotateZ(0);
        }
        to {
          transform: rotateX(1turn) rotateZ(1turn);
        }
      }
    </style>
  </head>
  <body>
    <div class="box">
      <ul class="minbox">
        <!-- 前 -->
        <li></li>
        <!-- 后 -->
        <li></li>
        <!-- 上 -->
        <li></li>
        <!-- 下 -->
        <li></li>
        <!-- 左 -->
        <li></li>
        <!-- 右 -->
        <li></li>
      </ul>
      <ol class="maxbox">
        <!-- 前 -->
        <li></li>
        <!-- 后 -->
        <li></li>
        <!-- 上 -->
        <li></li>
        <!-- 下 -->
        <li></li>
        <!-- 左 -->
        <li></li>
        <!-- 右 -->
        <li></li>
      </ol>
    </div>
  </body>
</html>
